﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>销售订单</title>
    <link rel="stylesheet" href="/layui/css/layui.min.css" />

    <style>
        .layui-table-total tr {
            background-color: #ffffff !important;
        }
    </style>
</head>
<body>
    <div id="tableSearch"></div>
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" id="table1" lay-filter="table1"></table>
        </div>
    </div>
    <script type="text/html" id="menu-toolbar">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>销售订单</legend>
        </fieldset>
    </script>
    <script src="/layui/layui.min.js"></script>
    <script>
        layui.config({ base: '/layui_exts/' }).extend({
            dynamicCondition: 'dynamicCondition/dynamicCondition'
        }).use(['table', 'layer', 'form', 'jquery', 'dynamicCondition'], function () {
            var layer = layui.layer, form = layui.form, table = layui.table;
            var $ = layui.jquery;
            let dynamicCondition = layui.dynamicCondition;
            var dc = dynamicCondition.create({
                type: "complex"
                , extendBtns: function (btnDivJq, instance) {
                    btnDivJq.append('<button class="layui-btn layui-btn-primary" id="config2">config2</button>');
                }
                , fields: [
                    { field: 'FBillNo', title: '单据编号', edit: 'text', ops: 'like,start,end,equal,unequal,in,notin' }
                    , { field: 'FMaterialName', title: '产品名称', edit: 'text', ops: 'like,start,end,notlike,equal,unequal' }
                    , { field: 'FPlanDate', title: '要货日期', edit: 'date', ops: 'between,greater_than,less_than' }
                    , { field: 'FMaterialId', title: '物料编码', edit: 'text', ops: 'like,start,end,equal,unequal' }
                    , { field: 'FMaterialModel', title: '型号规格', edit: 'text', ops: 'like,start,end,equal,unequal,empty,notempty' }
                    , { field: 'FCUSTIDFShortName', title: '客户名', edit: 'text', ops: 'like,start,end,equal,unequal' }
                    , { field: 'FQty', title: '数量', edit: 'text', ops: 'equal,unequal,between,greater_than,less_than,in,notin' }
                    , { field: 'FStockOutQty', title: '已出库数量', edit: 'text', ops: 'equal,unequal,between,greater_than,less_than' }
                    , { field: 'FRemainOutQty', title: '剩余未出数量', edit: 'text', ops: 'equal,unequal,between,greater_than,less_than' }
                ]
                , conditionTextId: "#tableSearch"
                , requestDataType: "json"
                , popupBtnsWidth: 350
                , popupShowQueryBtn: false
                , unpopupBtnswidth: 350
                , unpopupShowAddBtn: true
                , nestedQuery: false
                , opsMap: {
                    "equal": "等于", "like": "包含", "between": "范围"
                    , "start": "左包含", "end": "右包含", "notlike": "不包含", "unequal": "不等于", "empty": "为空", "notempty": "不为空", "greater_than": "大于", "less_than": "小于", "in": "IN", "notin": "Not IN"
                }
                , opsList: ["like", "start", "end", "notlike", "equal", "unequal", "empty", "notempty", "between", "greater_than", "less_than", "in", "notin"]
                , queryCallBack: function (requestData) {
                    table.reloadData('table1', {
                        page: {
                            curr: 1
                        }
                        , url: '/home/so'
                        , method: 'post'
                        , where: requestData
                    }, 'data');
                }
            });
            dc.setCondition([['FRemainOutQty', 'greater_than', '{{fStockOutQty}}', '{{fStockOutQty}}']]);
            var resData = table.render({
                elem: '#table1'
                , id: 'table1'
                , url: '/home/so'
                , method: 'post'
                , where: dynamicCondition.getInstance().buildRequestData()
                , cellMinWidth: 80
                , skin: 'line'
                , limits: [10, 50, 100, 500, 2000]
                , title: '销售订单'
                , toolbar: '#menu-toolbar'
                , defaultToolbar: ['filter', {
                    title: '引出Excel',
                    layEvent: 'excel',
                    icon: 'layui-icon-export'
                }]
                , cols: [[
                    { type: 'checkbox' }
                    , { field: 'FBillNo', title: '单据编号', width: 160, totalRowText: '合计:' }
                    , { field: 'FDate', title: '单据日期', width: 120 }
                    , { field: 'FDocumentStatus', title: '数据状态', width: 120 }
                    , { field: 'FCUSTID__FName', title: '客户名' }
                    , { field: 'FCUSTIDFShortName', title: '客户简称', width: 120 }
                    , { field: 'FMaterialId', title: '物料编码', width: 120 }
                    , { field: 'FMaterialName', title: '产品名称', width: 220 }
                    , { field: 'FMaterialModel', title: '规格型号', width: 100 }
                    , { field: 'FQty', title: '数量', width: 100, totalRow: true }
                    , { field: 'FPlanDate', title: '要货日期', width: 120 }
                    , { field: 'FStockOutQty', title: '已出库数量', width: 100, totalRow: true }
                    , { field: 'FRemainOutQty', title: '剩余未出数量', width: 110, totalRow: true }
                ]]
                , page: true
                , totalRow: true
            });

            table.on('toolbar(table1)', function (obj) {
                if (obj.event === 'excel') {
                    var url = '/Kingdee/Xsdd/Export';
                    formPost(url, dynamicCondition.getInstance().buildRequestData());
                }
            });
            $("#config2").click(function () {
                table.reloadData('table1', {
                    page: {
                        curr: 1
                    }
                    , url: '/home/so2'
                    , method: 'post'
                    , where: dynamicCondition.getInstance().buildRequestData()
                }, 'data');
            });
        });
        function formPost(URL, PARAMTERS) {
            var temp_form = document.createElement("form");
            temp_form.action = URL;
            temp_form.target = "_self";
            temp_form.method = "post";
            temp_form.style.display = "none";
            var opt = document.createElement("textarea");
            opt.name = "jsonStr";
            opt.value = PARAMTERS.jsonStr;
            temp_form.appendChild(opt);
            document.body.appendChild(temp_form);
            temp_form.submit();
        }
    </script>
</body>
</html>